﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Trilha
/// </summary>
public partial class Trilha
{
    public static List<Trilha> findAllByEvento(Guid idEvento)
    {
        DataClassesDataContext dc = new DataClassesDataContext();
        return dc.Trilhas.Where(p => p.idEvento.Equals(idEvento)).ToList();
    }
    public static bool existeTrilhaVinculadoNoArtigo(Guid idTrilha)
    {
        DataClassesDataContext dc = new DataClassesDataContext();
        return dc.Artigos.Any(p => p.idTrilha.Equals(idTrilha));
    }
    public static bool excludeTrilha(Guid idTrilha)
    {
        try
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            Trilha trilha = dc.Trilhas.Single(p => p.id.Equals(idTrilha));
            dc.Trilhas.DeleteOnSubmit(trilha);
            dc.SubmitChanges();
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
}